#include <iostream>
#include <vector>
using namespace std;

int P_seq[20];
int S_seq[20];
int size;
vector<int> paren;

const int LeftParen = -1;
const int RightParen = 1;

void P_to_paren()
{
    int last = 0;
    for (int i = 0; i < size; i++)
    {
        int leftParenCount = P_seq[i];
        for (int j = 0; j < leftParenCount - last; j++)
        {
            paren.push_back(LeftParen);
        }
        paren.push_back(RightParen);
        last = leftParenCount;
    }
}

void paren_to_S()
{
    for (int i = 1, k = 0; i < paren.size(); i++)
    {
        if (paren[i] != RightParen)
        {
            continue;
        }

        int count = 1;
        int match = RightParen;
        for (int j = i-1; j >=0; j--)
        {
            if (paren[j] == RightParen)
            {
                count++;
            }

            match += paren[j];
            if (match == 0)
            {
                break;
            }
        }
        S_seq[k++] = count;
    }
}

int main()
{
    int caseCount = 0;
    cin >> caseCount;
    for (int i = 0; i < caseCount; i++)
    {
        cin >> size;
        paren.clear();

        for (int j = 0; j < size; j++)
        {
            cin >> P_seq[j];
        }

        P_to_paren();
        paren_to_S();

        for (int j = 0; j < size; j++)
        {
            if (j > 0)
            {
                cout << ' ';
            }
            cout << S_seq[j];
        }
        cout << endl;
    }
}
